<?php
include_once "../header1.php";
?>
<script type="text/javascript">
function getHttpRequest()
{
if(window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
return xmlhttp;
}
function showHint(str)
{
var xmlhttp;    
if (str=="")
  {
  document.getElementById("List").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   document.getElementById("List").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","sch_names.php?q="+str,true);
xmlhttp.send();
}
function fill(val)
{
document.form1.SchName.value=val;
document.getElementById("List").innerHTML="";
var xmlhttp;    
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   document.getElementById("LId").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","getLabId.php?q="+val,true);
xmlhttp.send();
}
</script>
<link rel="stylesheet" href="../css/datepicker.css" type="text/css" />
    <link rel="stylesheet" media="screen" type="text/css" href="../css/layout.css" />
  	<script type="text/javascript" src="../js/jquery.js"></script>
	<script type="text/javascript" src="../js/datepicker.js"></script>
    <script type="text/javascript" src="../js/eye.js"></script>
    <script type="text/javascript" src="../js/utils.js"></script>
    <script type="text/javascript" src="../js/layout.js?ver=1.0.2"></script>
</head>
<body>
<?php
include_once ("../Login/databaseconnection.php");

if(!loggedin())
{
	require_once ("../index.php");
}
   
   else
   {
	   date_default_timezone_set("Europe/Paris");
    $t_d=date("Y-m-d");
 if(isset($_POST['Register']))
	   { 
$Lab_Category=$_POST['Lab_Category'];
$New_Lab_Category=$_POST['New_Lab_Category'];
$Lab_Type=$_POST['Lab_Type'];
$New_Lab_Type=$_POST['New_Lab_Type'];
$Lab_Id=$_POST['Lab_Id'];
         $Tp_Number=$_POST['Tp_Number'];
    $Account_Number=$_POST['Account_Number'];
$Date_of_commencement=$_POST['Date_of_commencement'];
	$Availability_Of_LAN=$_POST['Availability_Of_LAN'];
   $LAN_Supplier=$_POST['LAN_Supplier'];
 $Source_Of_Power=$_POST['Source_Of_Power'];
    $Supplied_Date=$_POST['Supplied_Date'];
   $Speed_Of_WAN=$_POST['Speed_Of_WAN'];
   $Wired_Date=$_POST['Wired_Date'];
   $WAN_Connection_Type=$_POST['WAN_Connection_Type'];
	$Internet_Facilities=$_POST['Internet_Facilities'];
	$SchName=$_POST['SchName'];
	$name=explode(",",$SchName);
    $nam=$name[0];
$tn=count($name);
for($i=1;$i<$tn;$i++)
{
if(empty($adr))
{
$adr=$name[$i];
}
else
{
$adr=$adr.",".$name[$i];
}
}
$results= mysql_query("SELECT * FROM school Where Name='$nam' AND Address='$adr'");
if($row = mysql_fetch_array($results))
{
 $School_Id=$row['School_Id'];
}
	if($SchName==""||$Lab_Id=="")
	   {
	   $_SESSION['errorin']="Please type the School Id and Lab Id!";
	   }
	   if($SchName!=""&&$Lab_Id!="")
	   {
$Lab_Che=mysql_query("SELECT * FROM lab WHERE School_Id='$School_Id' AND Lab_Id='$Lab_Id'");
if($rowl=mysql_fetch_array($Lab_Che))
		{
			$_SESSION['errorexi']="Sorry this Lab's record already exists";
		}
		else
		{
		if($_SESSION['Access_Type']=="Teacher in Charge")
{
   $NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id'];
  
   if($School_Id==$Own_School_Id)
	{
	require_once 'REG.php';
	}
		 else
	   {
	   $_SESSION['errornotallo']="Sorry you are not allowed to do this!";
	   }
		}
		}
		else if($_SESSION['Access_Type']=="Administrator")
{
require_once 'REG.php';
}   
   else
	   {
	   $_SESSION['errornotallo']="Sorry you are not allowed to do this!";
	   }
	}
	}
	}
?>
<?php
include_once "../header2.php";
?>
<?php
include_once "topmenu.php";
?>
 <div id="content">
	<div id="main">
	  <div id="bodyfield">
<br/>
<div id="lefttablereg">
  <form action="#" method="POST" name="form1">
  <table width="550" border="0" class="tablefontv">
    <tr>
      <td height="18" colspan="8" scope="row"><?php
		if(isset($_POST['Register']))
{
if(isset($_SESSION['error']))
	{
	if($_SESSION['OK']=="OK")
{
echo "<font color='green'>";
	echo '<img src="../images/tick.png" width="22" height="22"/>';
	}
	else
	{
echo "<font color='red'>";
	echo '<img src="../images/alert.jpg" width="12" height="12"/>';
	}
echo $_SESSION['error'];
		unset($_SESSION['error']);
	echo '</font>';
	}
if(isset($_SESSION['Lab_Id']))
	{
	$La_Id=$_SESSION['Lab_Id'];
	}
	if(isset($_SESSION['School_Id']))
	{
    $Sc_Id=$_SESSION['School_Id'];
	}
	
echo "<font color='red'>";
	if(isset($_SESSION['errorin']))
	{echo '<img src="../images/alert.jpg" width="12" height="12"/>';
		echo $_SESSION['errorin'];
		unset($_SESSION['errorin']);
		
	}
	if(isset($_SESSION['errorinnet']))
	{echo '<img src="../images/alert.jpg" width="12" height="12"/>';
		echo $_SESSION['errorinnet'];
		unset($_SESSION['errorinnet']);
		}
		if(isset($_SESSION['errorexi']))
	{echo '<img src="../images/alert.jpg" width="12" height="12"/>';
		echo $_SESSION['errorexi'];
		unset($_SESSION['errorexi']);
		
	}
	
echo "</font>";
}
		?></td>

    </tr>
       <tr>
       <td><font color="red" size="+2"><p align="center">*</p></font></td>
      <td width="-1" rowspan="16" scope="row"></td>
      <th width="120" height="22" scope="row">       
        School's Name:</th>
      <td width="-1">&nbsp;</td>
      <td width="169" height="22">
	  <form name="form" action="#" method="post"> 
      <?php
	  if(isset($_GET['s']))
	  {
	  $Sch_Id=$_GET['s'];
	  $snam=mysql_query("SELECT * FROM school WHERE School_Id='$Sch_Id'");
	  if($ros=mysql_fetch_array($snam))
	  {
	  $SchName=$ros['Name'].','.$ros['Address'];
	  }
	   echo "<input type='text' id='SchName' name='SchName' onKeyUp='showHint(this.value)' value='$SchName' onClick='cleartbox()' size='40' readonly='readonly'/>";
}
	  else
	  {
	 	if($_SESSION['Access_Type']=="Teacher in Charge")
{
	$NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id']; 
    $snam=mysql_query("SELECT * FROM school WHERE School_Id='$Own_School_Id'");
	  if($ros=mysql_fetch_array($snam))
	  {
	  $SchName=$ros['Name'].','.$ros['Address'];
	  }
}
	 echo "<input type='text' id='SchName' name='SchName' onKeyUp='showHint(this.value)' value='$SchName' onClick='cleartbox()' size='40' readonly='readonly'/>";
}
	else if($_SESSION['Access_Type']=="Administrator")
{
	    echo "<input type='text' id='SchName' name='SchName' onKeyUp='showHint(this.value)' value='$SchName' onClick='cleartbox()' size='40'/>";
}
}
	  ?>     
	</form>
	</td>
	</tr>
      <tr>
      <td><font color="red" size="+2"><p align="center">*</p></font></td>
      <th height="22" scope="row" >Lab Id:</th>
      <td width="-1">&nbsp;</td>
      <td><div id="LId"><?php	  
	   if(isset($_POST['Register']))
{
echo "<input type='text' name='Lab_Id' value='$Lab_Id' id='Lab_Id' readonly='readonly'/>";
}
else
{
if($_SESSION['Access_Type']=="Teacher in Charge")
	  {
$maxid=mysql_query("SELECT max(Lab_Id) as maxId FROM lab WHERE School_Id='$Own_School_Id'");
while($rowid=mysql_fetch_array($maxid))
{
$m_Id=$rowid['maxId'];
if($m_Id=="")
{
$L_Id="L0001";
}
else
{
$inum=substr("$m_Id",1);
$inn=($inum+1);
$r=(strlen($inum)-strlen($inn));
$L_Id='L';
if(strlen($inn)<strlen($inum))
{
for($i=0;$i<(strlen($inum)-strlen($inn));$i++)
{
$L_Id=$L_Id.'0';
}
$L_Id=$L_Id.$inn;
}
else
{
$L_Id=$L_Id.$inn;
}
}
}
echo "<input type='text' name='Lab_Id' id='Lab_Id' value='$L_Id' readonly='readonly'/>";
}
if($_SESSION['Access_Type']=="Administrator")
	  {
	  $Schoo_Id=$_POST['School_Id'];
	   if($Schoo_Id!="Select One")
	  {
	  $maxid=mysql_query("SELECT max(Lab_Id) as maxId FROM lab WHERE School_Id='$Schoo_Id'");
while($rowid=mysql_fetch_array($maxid))
{
$m_Id=$rowid['maxId'];
if($m_Id=="")
{
$L_Id="L0001";
}
else
{
$inum=substr("$m_Id",1);
$inn=($inum+1);
$r=(strlen($inum)-strlen($inn));
$L_Id='L';
if(strlen($inn)<strlen($inum))
{
for($i=0;$i<(strlen($inum)-strlen($inn));$i++)
{
$L_Id=$L_Id.'0';
}
$L_Id=$L_Id.$inn;
}
else
{
$L_Id=$L_Id.$inn;
}
}
}
echo "<input type='text' name='Lab_Id' id='Lab_Id' value='$L_Id' readonly='readonly'/>";
	  }
	   else
	  {
	  echo "<input type='text' name='Lab_Id' id='Lab_Id' readonly='readonly'/>";
	  }
	  }
}
?></div>
</td>     
    </tr>
    <tr>
      <td><font color="red" size="+2"><p align="center">*</p></font></td>
      <th height="22" scope="row">Lab Type: </th>
      <td width="-1">&nbsp;</td>
      <td>
	  <select name="Lab_Type" id="Lab_Type">
	  <?php	  
	  if(isset($_POST['Register']))
	  {
	 echo '<option value="'.$Lab_Type.'">'.$Lab_Type.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  }
	  $lab=mysql_query("SELECT DISTINCT(Lab_Type) FROM lab");	  
  while($row=mysql_fetch_array($lab))
  {  
  $L_Type=$row['Lab_Type'];  	  
if($L_Type!=$Lab_Type)
{
	echo '<option value="'.$L_Type.'">'.$L_Type.'</option>';
}
}
   ?>
      </select><br/><label><font color="red">or</font> New lab type:</label>&nbsp;&nbsp;&nbsp;
	  <?php
	  if($New_Lab_Type!="")
	  {
	  echo "<input type='text' name='New_Lab_Type' value='$New_Lab_Type'/>";
	  }
	  else
	  {
	  echo "<input type='text' name='New_Lab_Type'/>";
	  }
	  ?>
</td>     
    </tr>    
    <tr>
      <td><font color="red" size="+2"><p align="center">*</p></font></td>
      <th height="25" scope="row">Source Of Power: </th>
      <td width="-1">&nbsp;</td>
      <td>
        <?php
		 if(isset($_POST['Register']))
{  
echo "<input type='text' name='Source_Of_Power' value='$Source_Of_Power'/>";
}
else
{
echo "<input type='text' name='Source_Of_Power'/>";
}?></td>     
    </tr>
	<tr>
      <td><font color="red" size="+2"><p align="center">*</p></font></td>
      <th height="25" scope="row">Lab Category: </th>
      <td width="-1">&nbsp;</td>
      <td>
        <select name="Lab_Category" id="Lab_Category">
	  <?php
	  
	  if(isset($_POST['Register']))
	  {
	 echo '<option value="'.$Lab_Category.'">'.$Lab_Category.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  }
	  $lab=mysql_query("SELECT DISTINCT(Lab_Category) FROM lab");	  
  while($row=mysql_fetch_array($lab))
  {  
  $L_Category=$row['Lab_Category'];  	  
if($L_Category!=$Lab_Category)
{
	echo '<option value="'.$L_Category.'">'.$L_Category.'</option>';
}
}
   ?>
      </select><br/><label><font color="red">or</font> New lab category:</label>&nbsp;&nbsp;&nbsp;
	  <?php
	  if($New_Lab_Category!="")
	  {
	  echo "<input type='text' name='New_Lab_Category' value='$New_Lab_Category'/>";
	  }
	  else
	  {
	  echo "<input type='text' name='New_Lab_Category'/>";
	  }
	  ?>
	   </td>     
    </tr>
	<tr>
      <td><font color="red" size="+2"><p align="center"></p></font></td>
      <th height="25" scope="row">Special Projects: </th>
      <td width="-1">&nbsp;</td>
      <td>
<?php
$All_Special_Projects=="";
$OLPC="";
$Multimice="";
$IWB="";
$all_S_P=mysql_query("SELECT DISTINCT(Special_Project) FROM lab");
while($r_sp=mysql_fetch_array($all_S_P))
{
$sp_exists="";
$each_sp=explode(",",$r_sp['Special_Projects']);
$All_SProjects=explode(",",$All_Special_Projects);
for($spr=0;$spr<count($each_sp);$spr++)
{
if($each_sp[$spr]!="")
{
if(substr($each_sp[$spr],0,6)=="other_")
{
$each_sp[$spr]=substr($each_sp[$spr],6);
}
if($each_sp[$spr]=="OLPC")
{
$OLPC="exists";
}
else if($each_sp[$spr]=="Multimice")
{
$Multimice="exists";
}
else if($each_sp[$spr]=="IWB")
{
$IWB="exists";
}

for($s=0;$s<count($All_SProjects);$s++)
{
if($each_sp[$spr]==$All_SProjects[$s])
{
$sp_exists="yes";
break;
}
}
if($sp_exists!="yes")
{
if(empty($All_Special_Projects))
{
$All_Special_Projects=$each_sp[$spr];
}
else
{
$All_Special_Projects=$All_Special_Projects.",".$each_sp[$spr];
}
}
}
}
}
if($OLPC!="exists")
{
if(empty($All_Special_Projects))
{
$All_Special_Projects="OLPC";
}
else
{
$All_Special_Projects=$All_Special_Projects.",OLPC";
}
  }
  if($Multimice!="exists")
{
if(empty($All_Special_Projects))
{
$All_Special_Projects="Multimice";
}
else
{
$All_Special_Projects=$All_Special_Projects.",Multimice";
}
   }
   if($IWB!="exists")
{
if(empty($All_Special_Projects))
{
$All_Special_Projects="IWB";
}
else
{
$All_Special_Projects=$All_Special_Projects.",IWB";
}
   }
    
$All_Spe_Projects=explode(",",$All_Special_Projects);
  $other="";

echo '<div style="width:180px; height:150px; overflow-Y:scroll; ">';
if(isset($_POST['Register']))
{
if($Special_Projects!="")
{
$S_Proje= explode(",",$S_Pro);
for($s=0;$s<count($All_Spe_Projects);$s++)
{
$S_Proj="";
for($i=0;$i<count($S_Proje);$i++)
{
if($S_Proje[$i]==$All_Spe_Projects[$s])
{
$S_Proj="yes";
}
}
if($S_Proj=="yes")
{
echo "<input type='checkbox' name='Special_Projects[]' value='$All_Spe_Projects[$s]' checked='checked'/>";
  echo $All_Spe_Projects[$s];
    echo '<br/>';
  }
  else if($S_Proj=="")
  {
echo "<input type='checkbox' name='Special_Projects[]' value='$All_Spe_Projects[$s]'/>";
  echo $All_Spe_Projects[$s];
    echo '<br/>';
  }
else if(substr($All_Spe_Projects[$s],0,6)=="other_")
  {
  $other="exists";
    $sp=substr($All_Spe_Projects[$s],6);
	if($sp!="")
	{
echo "<input type='checkbox' name='Special_Projects[]' value='Others(P1.specify)' checked='checked'/>";
echo "Others";
  echo '<br/>';
  }
  else
  {
echo "<input type='checkbox' name='Special_Projects[]' value='Others(P1.specify)'/>";
echo "Others";
  echo '<br/>';
  }
?>
<textarea name='Special_Projects_Others'><?php echo $sp." "; ?></textarea>
<?php
}
}
if($other!="exists")
{
echo "<input type='checkbox' name='Special_Projects[]' value='Others(P1.specify)'/>";
echo "Others";
  echo '<br/>';
 ?>
<textarea name='Special_Projects_Others'></textarea>
<?php
}
}
else
{
for($sp=0;$sp<count($All_Spe_Projects);$sp++)
{
echo "<input type='checkbox' name='Special_Projects[]' value='$All_Spe_Projects[$sp]'/>";
echo "$All_Spe_Projects[$sp]";
echo '<br/>';
}
echo "<input type='checkbox' name='Special_Projects[]' value='Others(P1.specify)'/>";
echo "Others:";
  echo '<br/>';
echo "<textarea name='Special_Projects_Others'></textarea>";
}
}
else
{
for($sp=0;$sp<count($All_Spe_Projects);$sp++)
{
echo "<input type='checkbox' name='Special_Projects[]' value='$All_Spe_Projects[$sp]'/>";
echo "$All_Spe_Projects[$sp]";
echo '<br/>';
}
echo "<input type='checkbox' name='Special_Projects[]' value='Others(P1.specify)'/>";
echo "Others:";
  echo '<br/>';
echo "<textarea name='Special_Projects_Others'></textarea>";
}
?>
</td>     
    </tr>
    <tr>
         <td><font color="red" size="+2"><p align="center">*</p></font></td>
      <th height="29" scope="row">Telephone Number:</th>
      <td width="-1">&nbsp;</td>
      <td>
        <?php
	   if(isset($_POST['Register']))
{

echo "<input type='text' name='Tp_Number' value='$Tp_Number'/>";


}
else
{

echo "<input type='text' name='Tp_Number'/>";


}?></td>
     
    </tr>
    <tr>
      <th>&nbsp;</th>
      <th height="22" scope="row">Account Number: </th>
      <td width="-1">&nbsp;</td>
      <td>
        <?php
	   if(isset($_POST['Register']))
{
echo "<input type='text' name='Account_Number' value='$Account_Number'/>";
}
else
{

echo "<input type='text' name='Account_Number'/>";


}?></td>
     
    </tr>
    <tr>
      <td><font color="red" size="+2"><p align="center">*</p></font></td>
      <th height="30" scope="row">Date of commencement: </th>
      <td width="-1">&nbsp;</td>
      <td>
        <?php
	   if(isset($_POST['Register']))
{
echo "<input type='text' name='Date_of_commencement' value='$Date_of_commencement' class='inputDate' id='inputDate'>";
}
else
{
	echo "<input type='text' name='Date_of_commencement' class='inputDate' value='$t_d' id='inputDate'>";
}?></td>
     
    </tr>
	<tr>
        <td><font color="red" size="+2"><p align="center">*</p></font></td>
      <th height="27" scope="row">Internet Facilities: </th>
      <td>&nbsp;</td>
          <?php
		if(isset($_POST['Register']))
{
if($Internet_Facilities=="Yes")
{
echo '<td>';echo '<label>';
          echo '<input type="radio" name="Internet_Facilities" value="Yes" checked="checked"/>';
		  
          echo 'Yes';
		  echo '</label>';
        echo '<br />';
		}
		else
		{echo '<td>';echo '<label>';
          echo '<input type="radio" name="Internet_Facilities" value="Yes"/>';
		  
          echo 'Yes';
		  echo '</label>';
        echo '<br />';
		}        
		  if($Internet_Facilities=="No")
{
        echo '<label>';
          echo '<input type="radio" name="Internet_Facilities" value="No" checked="checked"/>';
          echo 'No';
		  echo '</label>';
		  echo '</td>';
		  }
		  else
		  {
		  echo '<label>';
          echo '<input type="radio" name="Internet_Facilities" value="No" />';
          echo 'No';
		  echo '</label>';
		  echo '</td>';
		  }
		 }
if(!isset($_POST['Register']))
{
echo '<td>';echo '<label>';
          echo '<input type="radio" name="Internet_Facilities" value="Yes"/>';
		  
          echo 'Yes';
		  echo '</label>';
        echo '<br />';
        echo '<label>';
          echo '<input type="radio" name="Internet_Facilities" value="No" />';
          echo 'No';
		  echo '</label>';
		  echo '</td>';
		  }
?>
    </tr>
    <tr>
        <td><font color="red" size="+2"><p align="center">*</p></font></td>
      <th height="27" scope="row">Availability of Lan: </th>
      <td>&nbsp;</td>
          <?php
		if(isset($_POST['Register']))
{
if($Availability_Of_LAN=="Yes")
{
echo '<td>';echo '<label>';
          echo '<input type="radio" name="Availability_Of_LAN" value="Yes" checked="checked"/>';
		  
          echo 'Yes';
		  echo '</label>';
        echo '<br />';
		}
		else
		{echo '<td>';echo '<label>';
          echo '<input type="radio" name="Availability_Of_LAN" value="Yes"/>';
		  
          echo 'Yes';
		  echo '</label>';
        echo '<br />';
		}
		
        
		  if($Availability_Of_LAN=="No")
{

        echo '<label>';
          echo '<input type="radio" name="Availability_Of_LAN" value="No" checked="checked"/>';
          echo 'No';
		  echo '</label>';
		  echo '</td>';
		  }
		  else
		  {echo '<label>';
          echo '<input type="radio" name="Availability_Of_LAN" value="No" />';
          echo 'No';
		  echo '</label>';
		  echo '</td>';
		  }
		 }
if(!isset($_POST['Register']))
{
echo '<td>';echo '<label>';
          echo '<input type="radio" name="Availability_Of_LAN" value="Yes"/>';
		  
          echo 'Yes';
		  echo '</label>';
        echo '<br />';
        echo '<label>';
          echo '<input type="radio" name="Availability_Of_LAN" value="No" />';
          echo 'No';
		  echo '</label>';
		  echo '</td>';
		  }
?>
    </tr>
	  <tr>
	    <th>&nbsp;</th>
	    <th height="28" scope="row">LAN Supplier: </th>
	    <td width="-1">&nbsp;</td>
      <td>
        <?php
	   if(isset($_POST['Register']))
{

echo "<input type='text' name='LAN_Supplier' value='$LAN_Supplier'/>";


}
else
{

echo "<input type='text' name='LAN_Supplier'/>";


}?></td>
    
      </tr>
 
	 <tr>
	        <th>&nbsp;</th>
	   <th height="22" scope="row">Supplied_Date: </th>
	   <td width="-1">&nbsp;</td>
      <td>
        <?php
	   if(isset($_POST['Register']))
{
echo "<input type='text' name='Supplied_Date' value='$Supplied_Date' class='inputDate1' id='inputDate1'>";
}
else
{
echo "<input type='text' name='Supplied_Date' class='inputDate1' value='$t_d' id='inputDate1'>";
}?></td>
     
    </tr>
    <tr>
      <th>&nbsp;</th>
      <th height="25" scope="row">Speed Of WAN: </th>
      <td width="-1">&nbsp;</td>
      <td>
        <?php
	   if(isset($_POST['Register']))
{

echo "<input type='text' name='Speed_Of_WAN' value='$Speed_Of_WAN'/>";


}
else
{

echo "<input type='text' name='Speed_Of_WAN'/>";


}?></td>
     
    </tr>
    
	 <tr>
	   <th>&nbsp;</th>
	   <th height="29" scope="row">WAN Connection Type: </th>
	   <td width="-1">&nbsp;</td>
      <td>
        <?php
	   if(isset($_POST['Register']))
{

echo "<input type='text' name='WAN_Connection_Type' value='$WAN_Connection_Type'/>";


}
else
{

echo "<input type='text' name='WAN_Connection_Type'/>";


}?></td>     
    </tr> 
	 <tr>
	   <th>&nbsp;</th>
	   <th height="26" scope="row">Wired Date: </th>
	   <td>&nbsp;</td>
      <td>
        <?php
	   if(isset($_POST['Register']))
{
echo "<input type='text' name='Wired_Date' value='$Wired_Date' class='inputDate2' value='$t_d' id='inputDate2'>";
}
else
{
echo "<input type='text' name='Wired_Date' value='$t_d' class='inputDate2' value='$t_d' id='inputDate2'>";

}?></td>
      <td width="121">
	 <a href="RegLab.php" class="reset">Reset |</a><input name="Register" align="middle" type="submit" value="Register" class="buttonok"/>
   <?php
if(isset($_POST['Register']))
{
if(isset($_SESSION['errornotallo']))
{echo '<img src="../images/alert.jpg" width="12" height="12"/>';
echo $_SESSION['errornotallo'];
unset($_SESSION['errornotallo']);
}
}
?> </td>
    </tr>
     </table>
  <br/>
  
 </form>
 </div>
 <div id="righttablereg">
<?php
 if($_SESSION['OK']!="OK")
{
?>
 <div class="suggestionListsch" id="List"></div>
<?php
}
		if(isset($_POST['Register']))
{
date_default_timezone_set("Europe/Paris");
    $t_d=date("Y-m-d");
if($_SESSION['OK']=="OK")
{
if($_SESSION['Access_Type']=="Teacher in Charge")
{
   $NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id'];
   $result=mysql_query("SELECT * FROM lab WHERE School_Id='$Own_School_Id'");
   echo '<br/>';
if(mysql_num_rows($result)!=0)
   {
   echo '<div style ="width:540px; height:500px; overflow-x:scroll; overflow-y:scroll;">';
   echo '<table width="30" border="1" class="righttable" >
<tr bgcolor="#6AB5FF">
<td><font color="#000000">Lab Id</font></td>
<td><font color="#000000">School Id</font></td>
<td><font color="#000000">Lab Type</font></td>
<td><font color="#000000">Telephone Number</font></td>
<td><font color="#000000">Account Number</font></td>
<td><font color="#000000">Date of Commencement</font></td>
<td><font color="#000000">Availability Of LAN</font></td>
<td><font color="#000000">LAN Supplier</font></td>
<td><font color="#000000">Source Of Power</font></td>
<td><font color="#000000">Supplied Date</font></td>
<td><font color="#000000">Wired Date</font></td>
<td><font color="#000000">Speed Of WAN</font></td>
<td><font color="#000000">WAN Connection Type</font></td>
<td><font color="#000000">Internet Facilities</font></td>
<td><font color="#000000">Last updated date</font></td>
</tr>';

  while($row=mysql_fetch_array($result))
  {
  $Sch_Id=$row['School_Id'];
$Lab_Id=$row['Lab_Id'];
	  $resultnet=mysql_query("SELECT * FROM network WHERE Lab_Id='$Lab_Id' AND School_Id='$Sch_Id'");


  while($rownet=mysql_fetch_array($resultnet))
  {
 $Availability_Of_LAN=$rownet['Availability_Of_LAN'];
    $LAN_Supplier=$rownet['LAN_Supplier'];
	$Supplied_Date=$rownet['Supplied_Date'];
    $Speed_Of_WAN=$rownet['Speed_Of_WAN'];
    $WAN_Connection_Type=$rownet['WAN_Connection_Type'];
    $Internet_Facilities=$rownet['Internet_Facilities'];
	$Wired_Date=$rownet['Wired_Date'];
	}

  if($row['Lab_Id']=="$La_Id"&&$row['School_Id']=="$Sc_Id")
  {
    echo '<tr bgcolor="#936">';
       echo '<td><font color="#000000">'.$row['Lab_Id'].'</font></td>';
    echo '<td><font color="#000000">'.$row['School_Id'].'</font></td>';
	echo '<td><font color="#000000">'.$row['Lab_Type'].'</font></td>';
    echo '<td><font color="#000000">'.$row['Tp_Number'].'</font></td>';
    echo '<td><font color="#000000">'.$row['Account_Number'].'</font></td>';
    echo '<td><font color="#000000">'.$row['Date_of_commencement'].'</font></td>';
	echo '<td><font color="#000000">'.$Availability_Of_LAN.'</font></td>';
	 echo '<td><font color="#000000">'.$LAN_Supplier.'</font></td>';
       echo '<td><font color="#000000">'.$row['$Source_Of_Power'].'</td>';
    echo '<td><font color="#000000">'.$Supplied_Date.'</td>';
	echo '<td><font color="#000000">'.$Wired_Date.'</font></td>';
		echo '<td><font color="#000000">'.$Speed_Of_WAN.'</font></td>';
	 echo '<td><font color="#000000">'.$WAN_Connection_Type.'</font></td>';
       echo '<td><font color="#000000">'.$Internet_Facilities.'</td>';
	    echo '<td><font color="#000000">'.$row['Last_updated_date'].'</font></td>';
  echo '</tr>';
  unset($_SESSION['$Lab_Id']);
  unset($_SESSION['School_Id']);
  }
 else
  {
    echo '<tr bgcolor="#CCCCCC">';
    echo '<td>'.$row['Lab_Id'].'</td>';
    echo '<td>'.$row['School_Id'].'</td>';
	  echo '<td>'.$row['Lab_Type'].'</td>';
    echo '<td>'.$row['Tp_Number'].'</td>';
    echo '<td>'.$row['Account_Number'].'</td>';
    echo '<td>'.$row['Date_of_commencement'].'</td>';
	echo '<td>'.$Availability_Of_LAN.'</td>';
	 echo '<td>'.$LAN_Supplier.'</td>';
       echo '<td>'.$row['Source_Of_Power'].'</td>';
    echo '<td>'.$Supplied_Date.'</td>';
	   echo '<td>'.$Wired_Date.'</td>';
	echo '<td>'.$Speed_Of_WAN.'</td>';
	 echo '<td>'.$WAN_Connection_Type.'</td>';
      echo '<td>'.$Internet_Facilities.'</td>';
    echo '<td>'.$row['Last_Updated_Date'].'</td>';
  echo '</tr>';
  }
  }
   echo "</table>";
   echo '</div>';
  }
 }
}
 if($_SESSION['Access_Type']=="Administrator")
{
$result=mysql_query("SELECT * FROM lab");
echo '<br/>';
if(mysql_num_rows($result)!=0)
   {
   echo '<div style ="width:540px; height:500px; overflow-x:scroll; overflow-y:scroll;">';
echo '<table width="30" border="1" class="righttable" >
<tr bgcolor="#6AB5FF">
<td><font color="#000000">Lab Id</font></td>
<td><font color="#000000">School Id</font></td>
<td><font color="#000000">Lab Type</font></td>
<td><font color="#000000">Telephone Number</font></td>
<td><font color="#000000">Account Number</font></td>
<td><font color="#000000">Date of Commencement</font></td>
<td><font color="#000000">Availability Of LAN</font></td>
<td><font color="#000000">LAN Supplier</font></td>
<td><font color="#000000">Source Of Power</font></td>
<td><font color="#000000">Supplied Date</font></td>
<td><font color="#000000">Wired Date</font></td>
<td><font color="#000000">Speed Of WAN</font></td>
<td><font color="#000000">WAN Connection Type</font></td>
<td><font color="#000000">Internet Facilities</font></td>
<td><font color="#000000">Last updated date</font></td>
</tr>';

  while($row=mysql_fetch_array($result))
  {$Sch_Id=$row['School_Id'];
$Lab_Id=$row['Lab_Id'];
	  $resultnet=mysql_query("SELECT * FROM network WHERE Lab_Id='$Lab_Id' AND School_Id='$Sch_Id'");


  while($rownet=mysql_fetch_array($resultnet))
  {
 $Availability_Of_LAN=$rownet['Availability_Of_LAN'];
    $LAN_Supplier=$rownet['LAN_Supplier'];
	$Supplied_Date=$rownet['Supplied_Date'];
    $Speed_Of_WAN=$rownet['Speed_Of_WAN'];
    $WAN_Connection_Type=$rownet['WAN_Connection_Type'];
    $Internet_Facilities=$rownet['Internet_Facilities'];
	$Wired_Date=$rownet['Wired_Date'];
	}
	  if($row['Lab_Id']=="$La_Id"&&$row['School_Id']=="$Sc_Id")
  {
    echo '<tr bgcolor="#936">';
    echo '<td><font color="#000000">'.$row['Lab_Id'].'</font></td>';
    echo '<td><font color="#000000">'.$row['School_Id'].'</font></td>';
	 echo '<td><font color="#000000">'.$row['Lab_Type'].'</font></td>';
    echo '<td><font color="#000000">'.$row['Tp_Number'].'</font></td>';
    echo '<td><font color="#000000">'.$row['Account_Number'].'</font></td>';
    echo '<td><font color="#000000">'.$row['Date_of_commencement'].'</font></td>';
	echo '<td><font color="#000000">'.$Availability_Of_LAN.'</font></td>';
	 echo '<td><font color="#000000">'.$LAN_Supplier.'</font></td>';
       echo '<td><font color="#000000">'.$row['$Source_Of_Power'].'</td>';
    echo '<td><font color="#000000">'.$Supplied_Date.'</td>';
	echo '<td><font color="#000000">'.$Wired_Date.'</font></td>';
		echo '<td><font color="#000000">'.$Speed_Of_WAN.'</font></td>';
	 echo '<td><font color="#000000">'.$WAN_Connection_Type.'</font></td>';
       echo '<td><font color="#000000">'.$Internet_Facilities.'</td>';
	    echo '<td><font color="#000000">'.$row['Last_updated_date'].'</font></td>';

  echo '</tr>';
  unset($_SESSION['$Lab_Id']);
  unset($_SESSION['School_Id']);
  }
 else
  {
    echo '<tr bgcolor="#CCCCCC">';
   echo '<td>'.$row['Lab_Id'].'</td>';
    echo '<td>'.$row['School_Id'].'</td>';
	   echo '<td>'.$row['Lab_Type'].'</td>';
    echo '<td>'.$row['Tp_Number'].'</td>';
    echo '<td>'.$row['Account_Number'].'</td>';
    echo '<td>'.$row['Date_of_commencement'].'</td>';
	echo '<td>'.$Availability_Of_LAN.'</td>';
	 echo '<td>'.$LAN_Supplier.'</td>';
       echo '<td>'.$row['Source_Of_Power'].'</td>';
    echo '<td>'.$Supplied_Date.'</td>';
	   echo '<td>'.$Wired_Date.'</td>';
	echo '<td>'.$Speed_Of_WAN.'</td>';
	 echo '<td>'.$WAN_Connection_Type.'</td>';
      echo '<td>'.$Internet_Facilities.'</td>';
    echo '<td>'.$row['Last_Updated_Date'].'</td>';
  echo '</tr>';
  }
  }
   echo "</table>";
   echo '</div>';
  }
  
  }
  unset($_SESSION['OK']);
  }
  }
  ?>
 </div>
</div>
</div>
</div>
<div id="sidebar">
<br/>
<div id="partners" class="boxed">
			<h2 class="title">LABS</h2>
            </div>
<?php
include_once "menu.php";
?> <?php
include_once "../footer.php";
?>

<?php

	}
?>
</body>
</html>